package icu.xuyijie.springbootlearning2.chapter1_2.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @author 徐一杰
 * @date 2025/02/21 11:19
 * @description 测试yml配置的值获取
 */
// 指定yml配置文件里的前缀
@ConfigurationProperties("my.config")
@Component
// 引入外部配置文件，只能是properties格式
@PropertySource("classpath:myy.properties")
public class TestYml {
    private String name;

    private String[] strings;

    private List<String> stringList;

    private Student student;

    private List<Student> studentList;

    private Map<String, Object> map;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String[] getStrings() {
        return strings;
    }

    public void setStrings(String[] strings) {
        this.strings = strings;
    }

    public List<String> getStringList() {
        return stringList;
    }

    public void setStringList(List<String> stringList) {
        this.stringList = stringList;
    }

    public Student getStudent() {
        return student;
    }

    public void setStudent(Student student) {
        this.student = student;
    }

    public Map<String, Object> getMap() {
        return map;
    }

    public void setMap(Map<String, Object> map) {
        this.map = map;
    }

    public List<Student> getStudentList() {
        return studentList;
    }

    public void setStudentList(List<Student> studentList) {
        this.studentList = studentList;
    }

    @Override
    public String toString() {
        return "TestYml{" +
                "name='" + name + '\'' +
                ", strings=" + Arrays.toString(strings) +
                ", stringList=" + stringList +
                ", student=" + student +
                ", studentList=" + studentList +
                ", map=" + map +
                '}';
    }
}
